<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="com.infomanage.enums.*"%>
<%@page import="org.hibernate.*"%>
<%@page import="org.hibernate.cfg.*"%>
<%@page import="java.util.*"%>
<%@page import="com.infomanage.po.*"%>
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<title>添加联系人</title>
	<link href="../../css/style.css" rel="stylesheet" type="text/css">
	<link href="../../css/table.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript">

		// 查询
	    function search() {
	    	var queryInputObj = document.getElementById("queryInputObj");	
			var querySelObj = document.getElementById("querySelObj");
			if(queryInputObj.style.display == ""){
				searchForm.queryValue.value = queryInputObj.value;
			}else {
				searchForm.queryValue.value = querySelObj.value;
			}
			//alert(searchForm.queryName.value + "=" + searchForm.queryValue.value);
	    	searchForm.submit();
		}


		// 切换查询项
		function changeQueryName(obj){
			var queryInputObj = document.getElementById("queryInputObj");	
			var querySelObj = document.getElementById("querySelObj");
			var queryName = obj.value;
			if(queryName == "name" ){
				queryInputObj.name="name";
				queryInputObj.style.display = "";
				querySelObj.style.display = "none";
				querySelObj.name="";
			}
			/*
			else if(queryName == "age"){
				queryInputObj.name="age";
				queryInputObj.style.display = "";
				querySelObj.style.display = "none";
			}
			*/
			else {
				queryInputObj.style.display = "none";
				querySelObj.style.display = "";
				querySelObj.options.length = 0;
				queryInputObj.name="";
				if(queryName == "degree"){
			    	addDegreeOptions(querySelObj);
					
			    }else if(queryName == "techlevel"){
			    	addTechlevelOptions(querySelObj);
					
			    }else if(queryName == "adminlevel"){
			    	addAdminOptions(querySelObj);
			    }
			}
	    }

	    // 添加查询值下来列表
	    
	    // 添加学历列表
	    function addDegreeOptions(selObj) {
	    	selObj.name = "highestDigree";
		    var opt = null;
			<%
		        Session session1 = HibernateSessionFactory.getSession();
				List list = null;
				try{
			        String Hql="From Department";
				    Query q = session1.createQuery(Hql);
				    list = q.list();
		    	}catch(Exception e){
		    		e.printStackTrace();
		    	}finally{
		    		session1.close();
		    	}
			
			    for(int i=0;i<list.size();i++) {
			    	Department dept=(Department)list.get(i);
			%>
				opt = new Option("<%=dept.getPath()%>", "<%=dept.getDeptId()%>");
				selObj.options.add(opt);     
				
			<%		
				}
			%>
	    }
	    
	    // 添加技术级别列表
	    function addTechlevelOptions(selObj) {
	  	  selObj.name = "techlevel";
		    var opt = null;
			<%
				for(TechnicDegreeType tech : TechnicDegreeType.values()) {
			%>
				opt = new Option("<%=tech.title()%>", "<%=tech.value()%>");
				selObj.options.add(opt);     
			<%		
				}
			%>
	    }
	    
	    // 添加行政级别列表
	    function addAdminOptions(selObj) {
	    	selObj.name = "adminlevel";
		    var opt = null;
			<%
				for(AdministrationDegreeType admin : AdministrationDegreeType.values()) {
			%>
				opt = new Option("<%=admin.title()%>", "<%=admin.value()%>");
				selObj.options.add(opt);     
			<%		
				}
			%>
	    }
	</script>
<body rightmargin="0" bottommargin="0" leftmargin="0" topmargin="0" onclick="clickBody();" style="background: #ffffff;">
<form name="searchForm" id="searchForm" action="personphone_data.jsp" target="dataFrame" method="get">
<table width="100%" height="100%"  border="0" align="center" cellpadding="0" cellspacing="0" style="table-layout: fixed;">
  <!-- 查询工具条 -->
   <tr height="29px">
	   <td valign="top">
	   		<table width="98%" height="29" cellpadding="0" cellspacing="0" align="center" border="0">
	   			<tr height="100%">
		   			<td class="td_title" width="420" align="left">
		   				<select name="queryName" style="width: 140px;margin-left: 5px;" onchange="changeQueryName(this);">
		   					<option value="name">姓名</option>
		   					<!-- option value="age">年龄</option> -->
		   					<option value="degree">部门</option>
		   				</select>
		   				<input type="hidden" name="queryValue">
		   				<input id="queryInputObj" name="name" type="text" style="width: 100">
		   				<select id="querySelObj" name="deptid" style="width: 125;display:none;"></select>
		   				
		   			</td>
		   			<td class="td_title" style="border-right: 1px #a3c6e2 solid;border-left: none;padding-left:20px;">
							<input name="Button12" type="button" class="button_cx" value="" title="查询" onclick="search();">
					</td>
	   			</tr>
	   		</table>
	   </td>
   </tr>
   
   <!-- 空格 -->
   <tr height="3px">
		<td>
			&nbsp;
		</td>
   </tr>
 <!-- 空格 -->
   <tr height="5px">
		<td>
			&nbsp;
		</td>
   </tr>
   
   <!-- 数据列表 -->
   <tr>
	<td align="center">
		<iframe src="personphone_data.jsp"  name="dataFrame" frameborder="0" width="98%" height="100%" scrolling="no"></iframe>
	</td>
   </tr>
</table>
<!-- 隐藏树 -->
<iframe src="#" frameborder="0" id="treeFrame" name="frame" style="display: none;position: absolute;"></iframe>
</form>

<!-- 批量删除表单  -->
<form action="personManage_action.jsp" name="delForm" target="actionFrame">
	<input type="hidden" value="delBatch" name="actionType">
	<input type="hidden" value="" name="batchIds">
</form>
<iframe src="#" name="actionFrame" style="display: none;"></iframe>
</body>
</html>
